<template>
  <a-modal
    :title="title + $t('活动')"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
    :cancelText="$t('关闭')"
    v-drag
  >
    <template slot="footer">
      <a-button @click="handleCancel">{{$t('取消')}}</a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <div>
        <a-row :gutter="24">
          <a-col
            :span="6"
            class="top-col"
            @click="handleAdd(item.value)"
            v-for="(item, indexs) in list"
            :key="indexs"
          >{{item.title}}</a-col>
        </a-row>
      </div>
    </a-spin>
    <add-game-activity-detail-modal ref="detailForm" @ok="detailOk"></add-game-activity-detail-modal>
  </a-modal>
</template>

<script>
import { initDictOptions } from '@/components/dict/JDictSelectUtil'
import AddGameActivityDetailModal from './AddGameActivityDetailModal'

export default {
  name: 'AddGameActivityModal',
  components: {
    AddGameActivityDetailModal
  },
  data() {
    return {
      width: 700,
      title: '',
      visible: false,
      model: {},
      confirmLoading: false,
      dataForm: {
        goodsId: ''
      },
      treeData: [],
      allChildKind: [],
      goodsList: [],
      value: '',
      list: []
    }
  },
  methods: {
    add() {
      this.visible = true
      initDictOptions('bis_game_activity.type').then(res => {
        if (res.success) {
          this.list = res.result
        }
      })
    },
    handleAdd(value) {
      if(value=='1'){
        this.$message.warning(this.$t('正在开发中~'))
        return
      }
      this.$refs.detailForm.add(value)
      this.$refs.detailForm.title = this.$t('新增')
      this.$refs.detailForm.disableSubmit = false
    },
    modalFormOk() {
      this.close()
      this.$emit('ok')
    },
    handleCancel() {
      this.close()
    },
    detailOk() {
      this.close()
      this.$emit('ok')
    },
    close() {
      this.visible = false
    }
  }
}
</script>
<style>
.batchForm .ant-form-item-label {
  width: 30%;
}
.batchForm .ant-form-item-control-wrapper {
  width: 62.5%;
}
.top-col {
  text-align: center;
  height: 60px;
  line-height: 60px;
  border-radius: 5px;
  margin: 0 20px 15px 20px;
  font-size: 16px;
  color: #ffff;
  background-color: #eb5467;
}
</style>